function foo () {
    console.log('1')
    throw(new Error('an error'))
    console.log('2')
    console.log('3')

}

try {
    foo()
} catch (err) {
    console.log(err.name)
    console.log(err.message)
}


// 1
// Error
// an error